package com.sl.plugin.step.script;

import cn.hutool.core.util.StrUtil;
import com.sl.core.engine.step.ProcessCompService;
import com.sl.core.engine.step.impl.AbstractProcessComp;
import lombok.SneakyThrows;

/**
 */
public class GroovyComp extends AbstractProcessComp<Object, Object> implements ProcessCompService {


    public GroovyComp(GroovyCompDescriptor groovyCompDescriptor) {
        super(groovyCompDescriptor);
    }


    @SneakyThrows
    @Override
    public Object input(Object driver) {
        String script = meta.getStrAttr("config.scripts");
        if (StrUtil.isBlank(script)) {
            //没有脚本就不进行了
            return null;
        }

        GroovyCompDescriptor descriptor = getDescriptor();
        Object o = descriptor.executeTestScript(script, driver);
        return o;
    }
}
